﻿using System.Windows;
using System.Collections.Generic;
using FireFly;
using System.Collections;

namespace XAMLStylePad.ViewModels.TriggersAndSetters
{
    public class MultiTriggerViewModel : TriggerViewModelBase<MultiTrigger>
    {
        public MultiTriggerViewModel(MultiTrigger MultiTrigger)
            : base(MultiTrigger)
        {

        }

        #region Setters
        public SetterCollectionViewModel Setters
        {
            get
            {
                if(_Setters == null)
                {
                    _Setters = new SetterCollectionViewModel(Model.Setters)
                    {
                        Parent = this,
                        DisplayName = "Setters"
                    };
                }
                return _Setters;
            }
        }
        SetterCollectionViewModel _Setters;
        #endregion

        #region Conditions
        public CollectionViewModel<Condition, ConditionViewModel> Conditions
        {
            get
            {
                if(_Conditions == null)
                {
                    _Conditions = new CollectionViewModel<Condition, ConditionViewModel>(Model.Conditions, o => new ConditionViewModel(o))
                    {
                        Parent = this,
                        DisplayName = "Conditions"
                    };
                }
                return _Conditions;
            }
        }
        CollectionViewModel<Condition, ConditionViewModel> _Conditions;
        #endregion

        public override string DisplayName
        {
            get
            {
                return string.Format("MultiTrigger[{0} condition(s)/{1} setter(s)]", Conditions != null ? Conditions.Count : 0, Setters != null ? Setters.Count : 0);
            }
        }

        public override ICollection VisualChildren
        {
            get
            {
                return ViewModelService.Instance.CombineVisualChildren(EnterActions, ExitActions, Conditions, Setters);
            }
        }
    }
}